package cn.wk.servlet;

import cn.wk.entity.Admins;
import cn.wk.entity.Teacher;
import cn.wk.services.AdminsServices;
import cn.wk.services.TeacherServices;
import cn.wk.services.impl.AdminsServicesImpl;
import cn.wk.services.impl.TeacherServicesImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/teacheredit")
public class Servletateacheredit extends HttpServlet {
    private TeacherServices as=new TeacherServicesImpl();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request,response);

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1. 接收转换
        request.setCharacterEncoding("utf-8");
        //2 接收数据
        int aid =Integer.parseInt(request.getParameter("tid"));
        Teacher teacher= as.findTeacherById(aid);
        if(teacher!=null){
            request.setAttribute("teacher",teacher);
            request.getRequestDispatcher("/teacher-add.jsp").forward(request,response);
        }
    }
}
